package cn.rocky.offer;

import java.util.Arrays;

public class offer40 {

    public int[] getLeastNumbers(int[] arr, int k) {
        int[] ans = new int[k];
        Arrays.sort(arr);
        for (int i = 0; i < k; i++) {
            ans[i] = arr[i];
        }
        return ans;
    }

    public static void main(String[] args) {
        offer40 offer40 = new offer40();
        int[] arr = new int[]{1,2,34,5,6,3};
        int k = 3;
        int[] leastNumbers = offer40.getLeastNumbers(arr, k);
        for (int i: leastNumbers) {
            System.out.println(i);
        }
    }
}
